function togglePopout() {
	$(".user-popout").toggle();
}

function login(id) {
	data = $("."+id).serialize();
	$.ajax({
			type:"POST",
			url: $("#project-base").val()+'Users',
			async: false,
			data: data,
			success:function(msg) {
				window.location.reload();
			},
			error:function(msg) {
				$("#"+id+"-error").html(msg.responseText);
			}
		});
}

function logout(action) {
	$.ajax({
			type:"POST",
			url: $("#project-base").val()+'Users',
			async: true,
			data: "action="+action,
			success:function(msg) {
				window.location.href=$("#project-base").val();
			}
		});
}

function deleteUser(action) {
	$("body").addClass("darken");
	if (!confirm("Delete all your data? (This cannot be undone)")) {
		togglePopout();
		$("body").removeClass("darken");
		return;
	}
	$("body").removeClass("darken");
	$.ajax({
		type:"POST",
		url:$("#project-base").val()+'Users',
		async: false,
		data: "action="+action,
		success:function(msg) {
			window.location.href=$("#project-base").val();
		},
		error:function(msg) {
			alert(msg.responseText);
		}
	});
}